package net.lab1024.sa.admin.module.business.supercomputer.selectfilds.dao.localdb;

import net.lab1024.sa.admin.module.business.supercomputer.selectfilds.domain.entity.ConnectionInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface SelectFieldsInLocalDBDao {

    /**
     * 向数据源表中data_source_name字段为sourceName的source_columns字段中存入columns
     */
    @Update("update smart_admin_v3.datasource set source_columns = #{columns} where data_source_id = " +
            "#{sourceId}")
    void saveColumn(@Param("sourceId") Integer sourceId, @Param("columns") String columns);

    /**
     * 获取数据源表名
     */
    @Select("select source_tablename \n" +
            "from smart_admin_v3.datasource " +
            "order by create_time desc limit 1 ")
    String getTableName();

    /**
     *获取连接信息
     */
    @Select("select conn_information from smart_admin_v3.datasource where data_source_id = #{sourceId}")
    String getConnectionInfo(@Param("sourceId") Integer sourceId);

}
